<?php

$db 	= new User();
$table  = "user";
$id		= "";
$user 	= $db->lihat_user($table,$id);

$o .= '<a href="?page=adduser"><i class="icon-plus"></i> Tambah Data</a><br>';
if ($user) {
	
	$o .= '<table class="table table-striped table-bordered table-condensed">
			<tr>
				<th><center>No</th>
				<th><center>Nama</th>
				<th><center>Username</th>
				<th><center>Email</th>
				<th><center>Hak Akses</th>
				<th><center>Sektoral</th>
				<th colspan=2><center>Tindakan</th>
			</tr>';
	
	$no = 1;
	
	foreach($user as $x) {
		if ($x['sektoral'] == 0) {
			$sektoral = "Tidak ada";
		} else {
			$sektoral = $x['sektoral'];
		}
		$o .= '<tr>
					<td><center>'.$no.'</td>
					<td><center>'.$x['nama_pegawai'].'</td>
					<td><center>'.$x['username'].'</td>
					<td><center>'.$x['email'].'</td>
					<td><center>'.$x['hak_akses'].'</td>
					<td><center>'.$sektoral.'</td>
					<td><center><a href="?page=edituser&id='.$x['username'].'"><i class="icon-wrench"></i> Ubah</a></td>
					<td><center><a href="#"><i class="icon-remove"></i> Hapus</a></td>
			  </tr>';
			  
		$no++;
		
	}

	$o .= '</table>';

} else {

	$o .= '<div class="alert alert-error">
		  <center>Data kosong</center>
		  </div>';
} 

echo $o;
